﻿using System;
using System.Collections.Generic;
using System.Text;
using DataProvider;
using System.Data;
using System.Data.SqlClient;

namespace BusinessLayer
{
    public class ThongKe:XL_Bang
    {
        public DataTable GetDataThongKeTinhHinhDatNhap()
        {
            try
            {
                open();
                command = new System.Data.SqlClient.SqlCommand();
                command.CommandText = "THONG_KE_TINH_HINH_DAT_NHAP";
                command.Connection = connect;
                command.CommandType = CommandType.StoredProcedure;
                SqlDataAdapter adapter = new SqlDataAdapter(command);
                DataTable table = new DataTable();
                adapter.Fill(table);
                close();
                return table;
            }
            catch (Exception)
            {
                return null;
            }
            finally
            {
                command.Dispose();
                close();
            }
        }

        public DataTable GetDataThongKeTinhHinhDatNhap(string soDH)
        {
            try
            {
                open();
                command = new System.Data.SqlClient.SqlCommand();
                command.CommandText = "THONG_KE_TINH_HINH_DAT_NHAP_THEO_SODH";
                command.Parameters.AddWithValue("@SODH", soDH);
                command.Connection = connect;
                command.CommandType = CommandType.StoredProcedure;
                SqlDataAdapter adapter = new SqlDataAdapter(command);
                DataTable table = new DataTable();
                adapter.Fill(table);
                close();
                return table;
            }
            catch (Exception)
            {
                return null;
            }
            finally
            {
                command.Dispose();
                close();
            }
        }

        public DataTable GetDataThongKeTongSLDatNhap()
        {
            try
            {
                open();
                command = new System.Data.SqlClient.SqlCommand();
                command.CommandText = "THONG_KE_TONG_SL_DAT_NHAP";
                command.Connection = connect;
                command.CommandType = CommandType.StoredProcedure;
                SqlDataAdapter adapter = new SqlDataAdapter(command);
                DataTable table = new DataTable();
                adapter.Fill(table);
                close();
                return table;
            }
            catch (Exception)
            {
                return null;
            }
            finally
            {
                command.Dispose();
                close();
            }
        }
    }
}
